/*
* $Id: unet.h,v 1.36 2008/02/26 03:09:50 chunchia Exp $
*/
/*******************************************************************************

       UBEC (Uniband Electronic Corp.)

       Project: U-NET01, Ubiquitous network platform

       File: unet.h

       Version: 0.3.0

       Usage:  Global variable defitions

       Platform: U-NET01 DK with Keil 8051 C compiler

       Reference:

               Silicon Laboratories: C8051F124, C8051F340

               UBEC: UZ2400, UZ2410

       Note :

               Copyright (C) 2007 Uniband Electronic Corporation, All rights reserved

********************************************************************************/

#ifndef _UNET_H_
#define	_UNET_H_

#include "config.h"
#include "Uz2400.h"
#include "type.h"
#include "api.h"
#include "data.h"
#include "debug.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>


// **********modified by jason 2008/5/20 05:20pm*************************************
//security

#include "tinysec/tinysec.h"
//***********************************************************************************












//System Message
#define FAILURE			0
#define SUCCESS			1
#define QUEUE_FULL		2
#define QUEUE_EMPTY		MSG_MAX_QUEUE_SIZE+1
#define PANID_INVALID		4
#define CHANNEL_INVALID		5
#define NETWORK_NOT_FOUND	6
#define PAN_ID_CONFLICT		7
#define JOIN_SUCCESS		8
#define DISCARD_FRAME		9
#define DATA_TOO_LONG		10
#define FOUND_NEXT_HOP		11
#define NEXT_HOP_NOT_AVAILABLE	12
#define SEND_TO_PARENT		13
#define DEST_IS_DEVSELF		14
#define TREE_ROUTING_FAILED	15
#define RETRY_EXCEED		16
#define SELF_HEAL_FAILED	17
#define SELF_HEAL_SUCCESS	18
#define CHILD_IN_TABLE		19
#define CHILD_FULL		20

// Max. payload length
#define MAC_MAX_DATA_PAYLOAD_LENGTH		102 // IEEE 802.15.4 Define
#define UNET_MAX_TX16_DATA_PAYLOAD_LENGTH	102
#define UNET_MAX_TX64_DATA_PAYLOAD_LENGTH	97

extern volatile INTERRUPT_STS IntStatus;
extern UNET_SYS UnetSys;
extern POLL poll;
#if !USE_BEACON_LIST
extern BEACON beacon;
#endif

extern volatile UINT32 tick_count;		/* 1 millisecond system timer tick counter */
extern volatile BOOL timer_1ms_flag;

extern UINT8 LQIValue;
extern UINT8 RSSIValue;
extern MAC_BCN_PKT route_info ; 

extern UINT8 AddrRecycleFlg;
extern UINT16 RecycleAddr;
extern UINT16 *RecycleAddress;
extern UINT8 RecycleIndex;

extern UINT16 tx_failure_address;

#ifdef CHECKSUM
extern UINT32 ReceivedNumber;
extern UINT16 RunIndex;
#endif

#ifdef CONSOLE
extern UART_INTERFACE UART_BUFF; // Uart receive buffer
#endif

extern UINT8 RF_TX_BUFF[128]; // RF transmit buffer
extern UINT8 MAC_ADDRESS[8];

extern TIMER *poll_tm;
extern TIMER *gettable_tm;
extern TIMER *reqtable_tm;
extern TIMER *chdalive_tm;
#if DEBUG_FUNC
extern TIMER *rssi_dbg_tm;
extern TIMER *child_number_dbg_tm;
extern uint8 dbg_child_number_flag;
extern uint8 dbg_child_number;
#endif

#endif // #ifndef _UNET_H_
